To receive a wireless message, set the message type and mailbox number to match those of the sending NXT. This block’s output can be the incoming message itself or a "true/false" logic value (if you are comparing the incoming message to a test message).
Before wireless messages can be sent or received, the participating NXTs must be set up for wireless communication.
On the (master) NXT that will communicate with other NXTs, navigate to the Bluetooth category and choose Search that will start a search for other devices. When the search is complete, choose which connection number (1, 2, or 3) you want the second (slave) NXT to be known as. The first time a connection is established between two NXTs, a prompt to enter the Passkey will appear on both NXTs; this needs to be accepted by both. Now when you navigate to the Connection category on the master NXT, the slave NXT should be shown by its name occupying the selected connection number. On the slave NXT, the master NXT should be shown occupying connection number 0. At this point, the master NXT is ready to initiate communication with the slave NXT.
If the master NXT needs to communicate with multiple NXTs (up to a maximum of three), you should repeat the above process again.
It’s only necessary to go through this process on one NXT. The receiving NXT will automatically update its connection when the master NXT is setting up its connection number.
The connection number for each NXT might be considered its address in the wireless world. You send a message to a specific NXT by indicating its connection number.
Each NXT has ten mailbox numbers where wireless messages can be deposited. Each mailbox number can hold up to five messages. If the mailbox number fills up with five messages, adding one more message will cause the NXT to erase the oldest message.
To receive a wireless message (after all NXTs have been configured with connection numbers), first indicate the format of the incoming message (Text, Number, or Logic).
If you want to test that a certain message has been received (and have the Receive Message block send out a "true" signal), type the test text or number in the input box, or check either true or false. If the incoming message, matches the test message, a "true" signal will be sent from the block through the "√/x" plug.
To finish configuring the block, choose the mailbox number where the incoming message will be stored.
Note: See the Send Message block for information on sending a wireless message.
The data hub will open automatically when the block is attached to a sequence beam. The incoming message will be sent as output from one of three data hub plugs depending on the message format: if the incoming message is in text format, it will be sent through the "T" plug; if the message is a number, it will be sent through the "#" plug; and if the message is a logic value, it will be sent through the "√/x" plug.
You can also send out a logic (true/false) signal through the "√/x" plug if you want to compare the incoming message to a test message you provide. (See the Data Hub section below for more information.)
You can control the Receive Message block dynamically by connecting data wires (from other blocks’ data hubs) to the Receive Message block’s data hub.
Open a block’s data hub by clicking the tab at the lower left edge of the block after it has been placed on the work area.
Data wires carrying input information to a block are connected to the plugs on the left side of its data hub. Data wires carrying output information are connected to the plugs on the right side.
[A] Input plug
[B] Output plug
[C] Number data wire (yellow)
[D] Logic data wire (green)
[E] Text data wire (orange)
[F] Broken data wire (gray)
If an input plug has a corresponding output plug (see A above), the input data will pass through from the input plug to the output plug without being changed. In this case, you can only use the output plug if the input plug is connected to an input data wire; connecting an output data wire to such an output plug without a connected input data wire will cause the output data wire to be "broken" (and colored gray).
Each data wire carries a specific type of data between blocks. For example, if a data wire is dragged from a logic plug on a block’s data hub, it can only be connected to a logic plug on another block’s data hub. The chart below shows what kind of data each plug can accept or send out.
Data wires are identified with specific colors: wires carrying number data are colored yellow, wires carrying logic data are colored green, and wires carrying text data are colored orange.
If you try to connect a data wire to a plug of the wrong data type, the data wire will be broken (and colored gray). You will not be able to download your program if a data wire is broken.
If you click a broken wire you can read why it is broken in the small help window in the lower right corner of the work area.
If an input data wire transmits a value outside the possible range of the plug it is connected to, the block will either ignore the value or change it to a value within its range. For plugs that allow just a few input values (example: just 0, 1, or 2), the plug will ignore the input if a value arrives outside its range.
For plugs that accept larger input ranges (example: 0 – 100), the plug will force any input outside its range to fit. For example, if a Move block’s Power plug receives an input value of 150, the block will change the input value to 100 (i.e., a number within the Power plug’s range).
Plug | Data Type | Possible Range | What the Values Mean | This Plug is Ignored When... | |
Mailbox | Number | 1 - 10 | Mailbox to read from | ||
Text in | Text | 58 character maximum | Value to compare against | Message Type not Text | |
Number in | Number | -2147483648 - 2147483647 | Value to compare against | Message Type not Number | |
Logic in | Logic | True/False | Value to compare against | Message Type not Logic | |
Message Received | Logic | True/False | True if a message is received (i.e., mailbox isn't empty) | ||
Yes / No | Logic | True/False | Result of comparison | ||
Text out | Text | 58 character maximum | Message data | Message Type not Text | |
Number out | Number | -2147483648 - 2147483647 | Message data | Message Type not Number | |
Logic out | Logic | True/False | Message data | Message Type not Logic |